#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;

int func(string s)
{
	if (s.size() == 0) return 0;
	int n = s.size();
	int left = 0, right = 0, len = 0;
	unordered_map<char, int> hash;
	while (right < n)
	{
		hash[s[right]]++;
		while (hash[s[right]] > 1)
		{
			hash[s[left]]--;
			left++;
		}
		len = max(len, right - left + 1);
		right++;
	}
	return len;
}
int main()
{
	string s = "abcabcbb";
	int ret = func(s);
	cout << ret << endl;
	return 0;
}